package priv.lhy.controller;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

/**
 * @author: lihy
 * date: 2020/1/11 16:08
 * description:
 */
@RestController
public class ClientController {

    @RequestMapping("/echo/{message}")
    public String echo(@PathVariable String message) {
        int sleepTime = 0;
        try {
            sleepTime = new Random().nextInt(3000);
            System.out.println("sleep: " + sleepTime);
            Thread.sleep(sleepTime);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return "延时" + sleepTime + "毫秒, [echo]: " + message;
    }
}
